<?php
require_once "../config/database.php";
class SqlComponent extends Object
{
    public $controller;


    /**
     * Constructor
     * @access protected
     */
    public function startup(&$controller)
    {
        $this->controller = $controller;
    }

    public function create_dump($filename)
    {
        $db = new DATABASE_CONFIG();
        Configure::load("admin");
        $mysqldump_path = Configure::read("mysqldump_path");

        $target = ROOT . DS . APP_DIR . DS . "db" . DS . "{$filename}";
        if ($db->default['password']) {
            $cmd = "{$mysqldump_path}".DS."mysqldump.exe --opt --databases {$db->default['database']} -u {$db->default['login']} -p {$db->default['password']} -h {$db->default['host']} > {$target}";
        } else {
            $cmd = "{$mysqldump_path}".DS."mysqldump.exe --opt --databases {$db->default['database']} -u {$db->default['login']} -h {$db->default['host']} > {$target}";
        }
        
        $result = system($cmd, $retval);
        return $retval;
    }

}
?>
